loadAll();
function onSave()
{
    if(typeof (Storage)!=="undefined")
    {
        var name=document.getElementById("sitename").value;
        var url=document.getElementById("siteurl").value;
        localStorage.setItem(name,url);
        alert("onSave");
    }
    else
    {
        alert("localStorge is not supported");
    }

}
function onFind()
{
    if(typeof (Storage)!=="undefined")
    {
        var name=document.getElementById("search_site").value;
        var url=localStorage.getItem(name);
        document.getElementById("find_result").innerHTML=name+"网址是："+url;
        alert("onFind");
    }
    else
    {
        alert("localStorge is not supported");
    }

}

function loadAll()
{
    var list=document.getElementById("list");
    if(typeof (Storage)!=="undefined")
    {

        var result="";
        if(localStorage.length<=0)
            return;
        result+="<table><tr><td>网站名</td><td>网址</td></tr>";
        for(var i=0;i<localStorage.length;i++)
        {
            var name=localStorage.key(i);
            var url=localStorage.getItem(name);
            result+="<tr><td>"+name+"</td><td>"+url+"</td></tr>";
        }
        result+="</table>";
        list.innerHTML=result;

    }
    else
    {
        alert("localStorge is not supported");
    }

}

function getclear()
{
    var content=document.getElementById("result");
    if(localStorage.length>0){
        localStorage.clear();
        content.innerHTML = "已清除……";
    }else{
        content.innerHTML = "数据为空……";
    }
}